//
//  MessageRifhtTableViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/2/7.
//

#import "MessageRifhtTableViewCell.h"

@implementation MessageRifhtTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    [self.contentView addSubview:self.avatarImageView];
    [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(52);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
    }];
    UIView * bgView = [[UIView alloc]init];
    bgView.layer.cornerRadius = 4;
    bgView.layer.masksToBounds = YES;
    bgView.backgroundColor = SQColor(@"#333333");
    [self.contentView addSubview:bgView];
    
    [self.contentView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.avatarImageView).offset(14);
        make.right.equalTo(self.contentView.mas_right).offset(-82);
    }];
   
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.messageLabel).insets(UIEdgeInsetsMake(-6, -6, -6, -6));
    }];
    self.FS_cellBottomView = self.messageLabel;
}
- (void)setModel:(MessageModel *)model{
    _model = model;
    self.avatarImageView.image = SQGetImage(model.portrait);
    self.messageLabel.text = model.content;
    [self.messageLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(model.cellSize.width);
        make.height.mas_equalTo(model.cellSize.height);
    }];
     
    
}

- (UIImageView *)avatarImageView{
    if (!_avatarImageView) {
        _avatarImageView = [[UIImageView alloc]init];
        _avatarImageView.clipsToBounds = YES;
        _avatarImageView.layer.cornerRadius = 8;
        _avatarImageView.layer.masksToBounds = YES;
        _avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _avatarImageView;
}

- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_REGULAR(14);
        _messageLabel.textColor = SQColor(@"#FFFFFF");
        _messageLabel.backgroundColor = UIColor.clearColor;
        _messageLabel.numberOfLines = 0;
     }
    return _messageLabel;
}

@end
